home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-26 | 3.9 KB | 132 lines | [TEXT/MPS ] |
- #
- # File: ThreeWayMerge
- #
- # Contains: xxx put contents here xxx
- #
- # This script compares merges two files that are assumed to be
- # derived from a base file. It does so by comparing both versions
- # with the base, sorting the resulting difference records, and then
- # processing them as actions on the base file. All changes from
- # both versions are included in the output. If both versions
- # affect the same lines in the base, then both versions are listed,
- # with ••• marks around the conflict.
- #
- #
- # Written by: Jens Alfke, William Cook, and Alex McKale
- #
- # Copyright: © 1992,1995-1996 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (most recent first):
- #
- # <2> 2/26/96 agm cleaned up for ETO 20.
- # <1> 5/25/95 jpa first checked in
- #
- # To Do:
- #
-
- # put out the things changed in the left file
- # could easily be changed to include a 'context' factor...
- # left = base, right = new
-
- if {#} < 3
- echo "usage: {0} <BaseFile> <Version1> <Version2>"
- exit
- end
-
- set original `files "{1}"`
- set new1 `files "{2}"`
- set new2 `files "{3}"`
- set temp "{TempFolder}ThreeWayMerge•"
-
- # compare the two new versions to the root version
- # and strip off the root version name
- set oldExit {exit}
- set exit 0
- Equal -q "{original}" "{new1}"
- if {status} == 0
- catenate "{new2}"
- exit
- end
- Equal -q "{original}" "{new2}"
- if {status} == 0
- catenate "{new1}"
- exit
- end
-
- compare -m -t -b "{original}" "{new1}" ∂
- | streamedit -d -e '/•[¬;]*; Line (≈)®1/ print ®1' > "{temp}"1
- compare -m -t -b "{original}" "{new2}" ∂
- | streamedit -d -e '/•[¬;]*; Line (≈)®1/ print ®1' > "{temp}"2
- set exit {oldExit}
-
- # sort the collected modifications by the order of changes
- # to the root file
- sort -fs " :;Δ" -f 1 -d "{temp}"1 "{temp}"2 > "{temp}"Sorted
-
- delete "{temp}"1 "{temp}"2
-
- # here we convert the "deltas" into a simple set of
- # commands. For each change entry, we do two things:
- # • output a command to dump the contents of the root
- # file from end of the last change (the start variable)
- # to the beginning of this change. These commands
- # get a "delete" variable binding too, which indicates
- # where the last change command began deleting from the
- # file. This lets us go back and print out deleted
- # text in case there was a conflict.
- # • then we make a change command for the new text (if any)
- # from one of the two deltas
- streamedit -d ∂
- -e "• ∂
- print 'Set InConflict 0'; ∂
- print 'Set LastChangeEnd -1'; ∂
- print 'Set CopyStart 1'" ∂
- -e "/•([0-9]+)®1;/ ∂
- print 'Set ChangeStart ' ®1; ∂
- print 'Set ChangeEnd ' ®1" ∂
- -e "/•([0-9]+)®1:([0-9]+)®2;/ ∂
- print 'Set ChangeStart ' ®1; ∂
- print 'Set ChangeEnd ' ®2" ∂
- -e "/•Δ([0-9]+)®1;/ ∂
- print 'Set ChangeStart ' ®1; ∂
- print 'Set ChangeEnd ∂`evaluate ' ®1 ' -1∂`'" ∂
- -e "/•([0-9]+)®1Δ;/ ∂
- print 'Set ChangeStart ∂`evaluate ' ®1 ' +1∂`'; ∂
- print 'Set ChangeEnd ' ®1" ∂
- -e "/; File (≈)®3; Line ([0-9]+)®1∞/ ∂
- print 'Set FileName ' ®3; ∂
- print 'Set NewStart ' ®1; ∂
- print 'Set NewEnd ' ®1; ∂
- print 'Execute ThreeWayMerge.Action'" ∂
- -e "/; File (≈)®3; Line ([0-9]+)®1:([0-9]+)®2∞/ ∂
- print 'Set FileName ' ®3; ∂
- print 'Set NewStart ' ®1; ∂
- print 'Set NewEnd ' ®2; ∂
- print 'Execute ThreeWayMerge.Action'" ∂
- -e "/; File (≈)®3; Line Δ([0-9]+)®1∞/ ∂
- print 'Set FileName ' ®3; ∂
- print 'Set NewStart ' ®1; ∂
- print 'Set NewEnd ∂`evaluate ' ®1 ' -1∂`'; ∂
- print 'Execute ThreeWayMerge.Action'" ∂
- -e "/; File (≈)®3; Line ([0-9]+)®1Δ∞/ ∂
- print 'Set FileName ' ®3; ∂
- print 'Set NewStart ∂`evaluate ' ®1 ' +1∂`'; ∂
- print 'Set NewEnd ' ®1; ∂
- print 'Execute ThreeWayMerge.Action'" ∂
- -e "∞ ∂
- print 'Set FileName ∂"∂"'; ∂
- print 'Set ChangeStart 9999999'; ∂
- print 'Set ChangeEnd 9999999'; ∂
- print 'Set NewStart 9999999'; ∂
- print 'Set NewEnd 9999999'; ∂
- print 'Execute ThreeWayMerge.Action'" ∂
- "{temp}"Sorted > "{temp}Commands"
-
- delete "{temp}"Sorted
-
- # now execute the program
-
- "{temp}Commands"
-
- delete "{temp}Commands"
-